Repository navigation
gfx/dmsh: specialize the blend fix-up away for pipelines whose blend words are both 0 (chain change) - #3176
Closed
dpadr wants to merge 3 commits into
Closed
gfx/dmsh: specialize the blend fix-up away for pipelines whose blend words are both 0 (chain change)#3176dpadr wants to merge 3 commits into
dpadr wants to merge 3 commits into
Conversation
…words are both 0 (chain change) dm_blend0 (dmsh_rewrite.py blend_zero) reads two words per draw: the zero-weight NaN rule and NVIDIA's float32 rounding into normalized targets. For most draws both are 0, and the read alone cost 2-6 % of Ocarina of Time's hottest pixel shaders on an M2 (fsbench: the words as constants run as fast as no fix-up at all). A new function constant dm_blend_off (DMSH_BLEND_OFF_FC 217) makes dm_blend0 return first. The host sets it per pipeline when the draw's words are both 0 (pso_key.blend_live, the key's former spare word; fn_off now takes a mask: FN_OFF_BORDER, FN_OFF_BLEND), as it does for the border corrections. That is 89 % of Ocarina of Time's draws and every hot pixel shader. Prewarm (pre_fn) and offline pipelines (pso_offline.py) take the common specialization; mesh, feedback and wide-line pipelines keep the fix-up. Pipelines with nonzero words read them as before, so the NaN and rounding cases are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ialized, as shader_load does The blend helper now declares dm_blend_off, and Metal builds no pipeline from a function with constants that was not specialized (shader_load specializes every such function with empty values; the tests took the plain function). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pso_bg_look's caller still passed the border-only flag (!qk->border), so a prediction looked up and built its base without dm_blend_off while the draw asks for pso_off(k): the worker never found the base the draw would use, and the draw compiled again. t_pso_bg_look builds its pulling base as a draw does (pso_off), and t_border's fn_off call takes the mask. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dpadr
force-pushed
the
nutmeg/blend-off-fc
branch
from
November 22, 2026 08:14
a7710c4 to
f0b0e1c
Compare
Contributor
Author
|
Rebased onto main (983a9ab), plus one fix.
|
seedds
added a commit
that referenced
this pull request
Nov 22, 2026
…(PR #3190) interface_check was the only place in scripts/regress.py that loaded a revision tree's Python tool in-process via load_module. Because pso_offline.py imports dmsh_abi, dmsh_side, romfs, shader_lib and vol_space by name, the baseline and candidate shared sys.modules (and got the harness checkout's romfs), causing a candidate that adds a dmsh_abi constant (such as PR #3176's DMSH_BLEND_OFF_FC) to fail with AttributeError against the baseline's header and risking silently masking helper differences. Run pso_offline.read_pairs/pair_text and (when suspects exist) pso_offline.plan through Tree.py with JSON over stdin instead, matching how regress.py already isolates dmsh_chain and game.py. Co-authored-by: David Padron-Harris <34929160+dpadr@users.noreply.github.com>
seedds
added a commit
that referenced
this pull request
Nov 23, 2026
…0 (PR #3176) Add function constant dm_blend_off (DMSH_BLEND_OFF_FC 217) to dm_blend0 so pipelines whose blend words (bz_word and rop_word) are both 0 compile out the buffer read and fix-up tail (-0.87 ms main pass, -4.6% GPU cycles on Ocarina of Time, M2 Air). Revises PR #3176 in three ways: - Derive pso_blend_live / pso_off directly from (pso_key, fs, merged) via bz_word_for / rop_word_for instead of adding a redundant pso_key field or reading global g_pass.cfmt / g_pso_lmap in pso_key_fill (fixes fsp_plan, fb_tile_ready, pso_predict_rest_, and preserves all existing pso_manifest.tsv / pso_user.tsv R and M rows). - Keep dm_blend_off = false in pso_offline.py, pre_fn, shader_load, and hybrid_get / pso_bg_look pulling lookups so 100% of bundled pair-archive pulling stand-ins remain valid across all blend states, while steady-state pipelines specialize dm_blend_off = true when both words are 0. - Add GPU and bundle tests for FN_OFF_BLEND, combined FN_OFF_BORDER | FN_OFF_BLEND, k->cfmt != g_pass.cfmt, and offline pair-archive lookup. Co-authored-by: David Padron-Harris <34929160+dpadr@users.noreply.github.com>
Owner
|
Thank you @dpadr for the diagnosis, the clean function-constant approach, and the M2 A/B measurements! Landed on
Checked locally on an Apple M6 Mac (host build, GPU blend/rounding/border/pipeline suites under Metal validation, and chain/archive/docs unit tests). Offline Metal compiler tests ( |
Kayyluhh
added a commit
to Kayyluhh/nxnative
that referenced
this pull request
Nov 23, 2026
…nk's probation (3d186f2) beside the batch's latency rules (seedds#1717's 30 Hz link, main's fine mode); chain f19baf01187e -> 4dbd705d26e9 (seedds#3176's blend fix-up); symptom index regenerated
Aznracer
added a commit
to Aznracer/Mighty-Green-Kokiri-Kid
that referenced
this pull request
Nov 23, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGrCTWig49u9S8ZCH37TUc
Aznracer
pushed a commit
to Aznracer/Mighty-Green-Kokiri-Kid
that referenced
this pull request
Nov 23, 2026
The 16:9 window crop is taken at the screen's shape in a texture of that shape. DM_NVN_BLEND_SPEC=0 keeps prewarm rows matching (seedds#3176 made draws wait). Memory pressure mode from 1200 MB of room. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGrCTWig49u9S8ZCH37TUc
Aznracer
pushed a commit
to Aznracer/Mighty-Green-Kokiri-Kid
that referenced
this pull request
Nov 23, 2026
…0 (PR seedds#3176) Add function constant dm_blend_off (DMSH_BLEND_OFF_FC 217) to dm_blend0 so pipelines whose blend words (bz_word and rop_word) are both 0 compile out the buffer read and fix-up tail (-0.87 ms main pass, -4.6% GPU cycles on Ocarina of Time, M2 Air). Revises PR seedds#3176 in three ways: - Derive pso_blend_live / pso_off directly from (pso_key, fs, merged) via bz_word_for / rop_word_for instead of adding a redundant pso_key field or reading global g_pass.cfmt / g_pso_lmap in pso_key_fill (fixes fsp_plan, fb_tile_ready, pso_predict_rest_, and preserves all existing pso_manifest.tsv / pso_user.tsv R and M rows). - Keep dm_blend_off = false in pso_offline.py, pre_fn, shader_load, and hybrid_get / pso_bg_look pulling lookups so 100% of bundled pair-archive pulling stand-ins remain valid across all blend states, while steady-state pipelines specialize dm_blend_off = true when both words are 0. - Add GPU and bundle tests for FN_OFF_BLEND, combined FN_OFF_BORDER | FN_OFF_BLEND, k->cfmt != g_pass.cfmt, and offline pair-archive lookup. Co-authored-by: David Padron-Harris <34929160+dpadr@users.noreply.github.com> (cherry picked from commit 3cf7506)
Aznracer
pushed a commit
to Aznracer/Mighty-Green-Kokiri-Kid
that referenced
this pull request
Nov 23, 2026
…y default); blend spec on the merged seedds#3176 form Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGrCTWig49u9S8ZCH37TUc
Aznracer
pushed a commit
to Aznracer/Mighty-Green-Kokiri-Kid
that referenced
this pull request
Nov 25, 2026
…(PR seedds#3190) interface_check was the only place in scripts/regress.py that loaded a revision tree's Python tool in-process via load_module. Because pso_offline.py imports dmsh_abi, dmsh_side, romfs, shader_lib and vol_space by name, the baseline and candidate shared sys.modules (and got the harness checkout's romfs), causing a candidate that adds a dmsh_abi constant (such as PR seedds#3176's DMSH_BLEND_OFF_FC) to fail with AttributeError against the baseline's header and risking silently masking helper differences. Run pso_offline.read_pairs/pair_text and (when suspects exist) pso_offline.plan through Tree.py with JSON over stdin instead, matching how regress.py already isolates dmsh_chain and game.py. Co-authored-by: David Padron-Harris <34929160+dpadr@users.noreply.github.com> (cherry picked from commit e531be8)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dm_blend0(theblend_zerofix-up) reads two words per draw: the zero-weight NaN rule (Ocarina of Time's mist) and NVIDIA's float32 rounding into normalized targets (Sonic Frontiers). For most draws both words are 0, yet every pixel shader still pays for the read, and it holds registers.This adds a function constant,
dm_blend_off(DMSH_BLEND_OFF_FC217), that makesdm_blend0return early.pso_key.blend_livetakes the key's spare word.fn_offtakes a mask (FN_OFF_BORDER,FN_OFF_BLEND).pre_fn,pso_offline.py) take the common specialization.This is a chain change:
dmsh_chain.his regenerated (26e1a5f38264 → 143cf4763549).Measurements (Ocarina of Time, M2 Air, the same change on the cut9s base)
In-game A/B (bfab23b: 3 runs per arm, Kokiri route, cap 60, frame gen off). GPU at 1397–1398 MHz in both arms, 0 % of the time in the power zone.
[RED]lines are the same in both arms (only the known 9b310b33 mismatch).Why there is no Ocarina of Time run on main: the A/B above ran on the cut9s base (chain f734e024449d). The change ported cleanly; the only adjustments were that
bz_word/rop_wordnow take the lane map (g_pso_lmap) and the two tests load specialized functions. Ocarina of Time is not in the regress set (it has no Mac build there), and a fresh baseline pair on main would take about two hours of the shared Mac's queue for a result the cut9s A/B and the guard tests already cover.Checks on this branch (a7710c4)
t_nvn506 passed, 0 failed;t_pso_skeyOK.t_blend_zero: 197 / 0.t_rop_round: 9284 / 0.t_rop_roundcovers Sonic Frontiers' rounding case; the game itself isn't available locally.scripts/regress.py check --gamesagainst 656f884 (this branch's base):0400380020056000010020D01AD2400001004F90239BA000pso_offline.pyshare onedmsh_abimodule in a single process. On currentregress.py, a candidate that adds admsh_abiconstant fails the interface check with the baseline's header. The table above was produced with that fixed locally; the fix will be sent as its own PR.🤖 Generated with Claude Code